/*
 * @Author: jinye.zhang
 * @Version: 1.0.0
 * @Date: 2021-04-21 08:49:14
 * @LastEditors: jinye
 * @LastEditTime: 2023-05-12 15:42:25
 * @Description: vuex
 */
import Vue from 'vue'
import Vuex from 'vuex'
import config from '../utils/config'
Vue.use(Vuex)
const store = new Vuex.Store({
    state: {
			userInfo: {}, // 用户信息
      appletInfo: {}, // 应用信息
      designAddress: null,
			token: '', // token
      isLogin: false, // 是否登录
      safeAreaBottomHeight: 0, // 底部安全高度
      checkingVersion: '1.0.0', // 审核版本
      version: config.version, // 版本
      loginShow: false, // 登录显示
      questionDetail: {
        title: '',
        content: ''
      },
      authorInfo: {}, // 作者信息
      userStatistics: {}, // 用户信息统计
      userIncomeData: {}, // 收益统计
      artworksTypeAllListData: [], // 作品类型l
      setPostList: [] // 海报列表
		},
    mutations: {
			SET_USER_INFO: (state, userInfo) => {
				state.userInfo = userInfo;
			},
			SET_TOKEN: (state, token) => {
				state.token = token;
			},
      SET_LOGIN_STATUS: (state, isLogin) => {
        state.isLogin = isLogin;
      },
      SET_DESIGN_ADDRESS: (state, designAddress) => {
        state.designAddress = designAddress;
      },
      SET_IS_LOGIN: (state, isLogin) => {
        state.isLogin = isLogin;
      },
      SET_SHOW_LOGIN: (state, loginShow) => {
        state.loginShow = loginShow;
      },
      SET_APPLET_INFO: (state, appletInfo) => {
        state.appletInfo = appletInfo;
      },
      SET_QUESTION_DETAIL: (state, questionDetail) => {
        state.questionDetail = questionDetail;
      },
      SET_CHECK_VERSION: (state, checkingVersion) => {
        state.checkingVersion = checkingVersion;
      },
      SET_SAFEAREA_BOTTOM_HEIGHT: (state, safeAreaBottomHeight) => {
        state.safeAreaBottomHeight = safeAreaBottomHeight;
      },
      SET_AUTHOR_INFO: (state, authorInfo) => {
        state.authorInfo = authorInfo;
      },
      SET_USER_STATISTICS: (state, userStatistics) => {
        state.userStatistics = userStatistics;
      },
      SET_ARTWORKS_ALL_LIST: (state, artworksTypeAllListData) => {
        state.artworksTypeAllListData = artworksTypeAllListData;
      },
      SET_POSTER_LIST: (state, posterList) => {
        state.posterList = posterList;
      },
      SET_USER_INCOME_DATA: (state, userIncomeData) => {
        state.userIncomeData = userIncomeData;
      },
		},
    actions: {
			async setUserInfo({ commit }, userInfo) {
				commit('SET_USER_INFO', userInfo);
			},
			async setToken({ commit }, token) {
				commit('SET_TOKEN', token);
			},
			async setLoginStatus({ commit }, isLogin) {
				commit('SET_LOGIN_STATUS', isLogin);
			},
			async setDesignAddress({ commit }, designAddress) {
				commit('SET_DESIGN_ADDRESS', designAddress);
			},
			async setIsLogin({ commit }, isLogin) {
				commit('SET_IS_LOGIN', isLogin);
			},
			async setShowLogin({ commit }, loginShow) {
				commit('SET_SHOW_LOGIN', loginShow);
			},
			async setAppletInfo({ commit }, appletInfo) {
				commit('SET_APPLET_INFO', appletInfo);
			},
			async setQuestionDetail({ commit }, questionDetail) {
				commit('SET_QUESTION_DETAIL', questionDetail);
			},
			async setCheckVersion({ commit }, checkingVersion) {
				commit('SET_CHECK_VERSION', checkingVersion);
			},
			async setsafeAreaBottomHeight({ commit }, safeAreaBottomHeight) {
				commit('SET_SAFEAREA_BOTTOM_HEIGHT', safeAreaBottomHeight);
			},
			async setAuthorInfo({ commit }, authorInfo) {
				commit('SET_AUTHOR_INFO', authorInfo);
			},
			async setUserStatistics({ commit }, userStatistics) {
				commit('SET_USER_STATISTICS', userStatistics);
			},
      async setUserIncomeData({ commit }, userIncomeData) {
				commit('SET_USER_INCOME_DATA', userIncomeData);
			},
			async setArtworksAllListData({ commit }, artworksTypeAllListData) {
				commit('SET_ARTWORKS_ALL_LIST', artworksTypeAllListData);
			},
			async setPostList({ commit }, posterList) {
				commit('SET_POSTER_LIST', posterList);
			}
		},
		getters: {
			userInfo(state) {
				return state.userInfo;
			},
			token(state) {
				return state.token;
			},
      isLogin(state) {
        return state.isLogin;
      },
      designAddress(state) {
        return state.designAddress;
      },
      loginShow(state) {
        return state.loginShow;
      },
      appletInfo(state) {
        return state.appletInfo;
      },
      checkingVersion(state) {
        return state.checkingVersion;
      },
      version(state) {
        return state.version;
      },
      questionDetail(state) {
        return state.questionDetail;
      },
      safeAreaBottomHeight(state) {
        return state.safeAreaBottomHeight;
      },
      authorInfo(state) {
        return state.authorInfo;
      },
      userStatistics(state) {
        return state.userStatistics;
      },
      userIncomeData(state) {
        return state.userIncomeData;
      },
      artworksTypeAllListData(state) {
        return state.artworksTypeAllListData;
      },
      posterList(state) {
        return state.posterList;
      }
		}
})
export default store